package io.RandomAccessFile;

import java.io.File;
import java.io.RandomAccessFile;

public class Demo01RandomAccessFile {
    public static void main(String[] args) throws Exception {
        RandomAccessFile raf1 = new RandomAccessFile(new File("F://Test//T4//a.txt"), "r");
        RandomAccessFile raf2 = new RandomAccessFile(new File("F://Test//T4//b.txt"), "rw");

        byte[] bytes = new byte[1024];
        int length;
        raf2.seek(raf2.length());
        while ((length = raf1.read(bytes)) != -1) {
            raf2.write(bytes, 0, length);
            System.out.println(new String(bytes, 0, length));
        }
    }
}
